package com.fortune.service.impl;

import com.fortune.dao.DriverDao;
import com.fortune.entity.PhoneAndPassword;
import com.fortune.service.DriverService;
import com.fortune.vo.driver.DriverPersonalInfo;
import com.fortune.vo.salesMan.LoginSalesManInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DriverServiceImpl implements DriverService {
    @Autowired
    private DriverDao driverDao;

    /**
     * 验证当前登录账号是否存在
     * @param phone
     * @return
     */
    @Override
    public PhoneAndPassword findPhoneAndPassword(String phone) {
        PhoneAndPassword findPhoneAndPassword = driverDao.findPhoneAndPassword(phone);
        return findPhoneAndPassword;
    }

    /**
     * 查询登录成功返回的信息
     * @param phone
     * @return
     */
    @Override
    public LoginSalesManInfo findLoginSalesManInfo(String phone) {
        LoginSalesManInfo findLoginSalesManInfo = driverDao.findLoginSalesManInfo(phone);
        return findLoginSalesManInfo;
    }

    /**
     * 忘记密码
     * @param phone
     * @param password
     * @return
     */
    @Override
    public int editPasswordByPhoneAndCode(String phone, String password) {
        int editPasswordByPhoneAndCode = driverDao.editPasswordByPhoneAndCode(phone, password);
        return editPasswordByPhoneAndCode;
    }

    /**
     * 司机个人信息
     * @param did
     * @param userId
     * @return
     */
    @Override
    public DriverPersonalInfo findDriverPersonalInfo(String did, String userId) {
        DriverPersonalInfo findDriverPersonalInfo = driverDao.findDriverPersonalInfo(did, userId);
        return findDriverPersonalInfo;
    }

    /**
     * 修改司机姓名
     * @param mid
     * @param did
     * @param userId
     * @param name
     * @return
     */
    @Override
    public int editDriverName(String did, String userId, String name) {
        int editDriverName = driverDao.editDriverName(did, userId, name);
        return editDriverName;
    }

    /**
     * 修改司机手机号
     * @param mid
     * @param did
     * @param userId
     * @param newPhone
     * @return
     */
    @Override
    public int editDriverPhone(String did, String userId, String newPhone) {
        int editDriverPhone = driverDao.editDriverPhone(did, userId, newPhone);
        return editDriverPhone;
    }

    /**
     * 验证当前登陆账号是不是司机
     * @param phone
     * @return
     */
    @Override
    public String findPostByPhone(String phone) {
        String findPostByPhone = driverDao.findPostByPhone(phone);
        return findPostByPhone;
    }

    /**
     * 修改密码
     * @param did
     * @param userId
     * @return
     */
    @Override
    public int editNewPSW(String did, String userId, String newPassword) {
        return driverDao.editNewPSW(did, userId, newPassword);
    }
}
